/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.sentry;

import io.sentry.protocol.SentryId;
import io.sentry.protocol.SentryTransaction;
import io.sentry.protocol.User;

import java.util.List;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * NoOpHub
 *
 * @since 2021-06-02
 **/
public final class NoOpHub implements IHub {
    private static final NoOpHub INSTANCE = new NoOpHub();

    private final @NotNull SentryOptions emptyOptions = SentryOptions.empty();

    private NoOpHub() {
    }

    public static NoOpHub getInstance() {
        return INSTANCE;
    }

    @Override
    public boolean isEnabled() {
        return false;
    }

    @Override
    public @NotNull SentryId captureEvent(@NotNull SentryEvent event, @Nullable Object hint) {
        return SentryId.EMPTY_ID;
    }

    @Override
    public @NotNull SentryId captureMessage(@NotNull String message, @NotNull SentryLevel level) {
        return SentryId.EMPTY_ID;
    }

    @Override
    public @NotNull SentryId captureEnvelope(
        @NotNull SentryEnvelope envelope, @Nullable Object hint) {
        return SentryId.EMPTY_ID;
    }

    @Override
    public @NotNull SentryId captureException(@NotNull Throwable throwable, @Nullable Object hint) {
        return SentryId.EMPTY_ID;
    }

    @Override
    public void captureUserFeedback(@NotNull UserFeedback userFeedback) {
    }

    @Override
    public void startSession() {
    }

    @Override
    public void endSession() {
    }

    @Override
    public void close() {
    }

    @Override
    public void addBreadcrumb(@NotNull Breadcrumb breadcrumb, @Nullable Object hint) {
    }

    @Override
    public void setLevel(@Nullable SentryLevel level) {
    }

    @Override
    public void setTransaction(@Nullable String transaction) {
    }

    @Override
    public void setUser(@Nullable User user) {
    }

    @Override
    public void setFingerprint(@NotNull List<String> fingerprint) {
    }

    @Override
    public void clearBreadcrumbs() {
    }

    @Override
    public void setTag(@NotNull String key, @NotNull String value) {
    }

    @Override
    public void removeTag(@NotNull String key) {
    }

    @Override
    public void setExtra(@NotNull String key, @NotNull String value) {
    }

    @Override
    public void removeExtra(@NotNull String key) {
    }

    @Override
    public @NotNull SentryId getLastEventId() {
        return SentryId.EMPTY_ID;
    }

    @Override
    public void pushScope() {
    }

    @Override
    public void popScope() {
    }

    @Override
    public void withScope(@NotNull ScopeCallback callback) {
    }

    @Override
    public void configureScope(@NotNull ScopeCallback callback) {
    }

    @Override
    public void bindClient(@NotNull ISentryClient client) {
    }

    @Override
    public void flush(long timeoutMillis) {
    }

    @Override
    public @NotNull IHub cloneHub() {
        return INSTANCE;
    }

    @Override
    public @NotNull SentryId captureTransaction(
        final @NotNull SentryTransaction transaction, final @Nullable Object hint) {
        return SentryId.EMPTY_ID;
    }

    @Override
    public @NotNull ITransaction startTransaction(@NotNull TransactionContext transactionContexts) {
        return NoOpTransaction.getInstance();
    }

    @Override
    public @NotNull ITransaction startTransaction(
        @NotNull TransactionContext transactionContexts,
        @Nullable CustomSamplingContext customSamplingContext,
        boolean bindToScope) {
        return NoOpTransaction.getInstance();
    }

    @Override
    public @NotNull SentryTraceHeader traceHeaders() {
        return new SentryTraceHeader(SentryId.EMPTY_ID, SpanId.EMPTY_ID, true);
    }

    @Override
    public void setSpanContext(
        final @NotNull Throwable throwable,
        final @NotNull ISpan spanContext,
        final @NotNull String transactionName) {
    }

    @Override
    public @Nullable ISpan getSpan() {
        return null;
    }

    @Override
    public @NotNull SentryOptions getOptions() {
        return emptyOptions;
    }
}
